#include <iostream>
using namespace std;

class Person 
{
public:
    Person(){
        cout<< "Person()"<<endl;
    }
    virtual ~Person(){
        cout<< "~Person()"<<endl;
    }
    virtual void work(){
        cout <<"Person::work()"<<endl;
    }   
};

class Student: virtual public Person
{
public:
    Student(){
        cout<< "Student()"<<endl;
    }
    virtual ~Student(){
        cout << "~Student()"<<endl;
    }
    virtual void work(){
        cout <<"Student::work()"<<endl;
    }    
};
class Teacher: public Person
{
public:
    Teacher(){
        cout << "Teacher()"<<endl;
    }
    virtual ~Teacher(){
        cout << "~Teacher()"<<endl;
    }
    virtual void work(){
        cout <<"Teacher::work()"<<endl;
    }
};

int main(){
  
    Person *p = new Person;
    Person *s = new Student;
    Person *t = new Teacher;
    p->work();
    s->work();
    t->work();
    delete p;
    p = nullptr;
    delete s;
    s = nullptr;
    delete t;
    t = nullptr;
    return 0;  
}